{ "metadata": { "name": "", "signature": "sha256:cca24d21958b8882ea9199cf6047088a5e1fbb1faceae8058e342ea559fea1cb" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import plotly.plotly as py\n", "from plotly.graph_objs import *" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "/Users/chris/anaconda/lib/python2.7/site-packages/pandas/computation/expressions.py:21: UserWarning: The installed version of numexpr 2.0.1 is not supported in pandas and will be not be used\n", "The minimum supported version is 2.1\n", "\n", " \"version is 2.1\\n\".format(ver=ver), UserWarning)\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from plotly.widgets import GraphWidget" ], "language": "python", "metadata": {}, "outputs": [ { "javascript": [ "window.genUID = function() {\n", " return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n", " var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);\n", " return v.toString(16);\n", " });\n", "};\n", "\n", "require([\"widgets/js/widget\"], function(WidgetManager){\n", "\n", " var GraphView = IPython.DOMWidgetView.extend({\n", " render: function(){\n", "\n", " console.log('render!');\n", "\n", " var that = this;\n", "\n", " var graphId = window.genUID();\n", " var loadingId = 'loading-'+graphId;\n", "\n", "\n", " var _graph_url = that.model.get('_graph_url');\n", "\n", " // variable plotlyDomain in the case of enterprise\n", " var url_parts = _graph_url.split('/');\n", " var plotlyDomain = url_parts[0] + '//' + url_parts[2];\n", "\n", " if(!('plotlyDomains' in window)){\n", " window.plotlyDomains = {};\n", " }\n", " window.plotlyDomains[graphId] = plotlyDomain;\n", "\n", " // Place IFrame in output cell div `$el`\n", " that.$el.css('width', '100%');\n", " that.$graph = $([''].join(' '));\n", " that.$graph.appendTo(that.$el);\n", "\n", " that.$loading = $('